home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 March / Macworld (1998-03) (Disk 1).dmg / Shareware World / Utilities / Text Processing / Alpha / Tcl / SystemCode / AlphaBits.tcl next >
Encoding:
Text File  |  1997-12-10  |  3.7 KB  |  131 lines  |  [TEXT/ALFA]

  1. # First basic initialisation:
  2. if [catch {
  3.     # Get Alpha's current name.
  4.     regexp {"([^"]+)" "ALFA" } [processes] "" ALPHA
  5.     # PREFS points to a folder 'Alpha', we add the major version number
  6.     set alpha::version [lindex [split [version] ,] 0]
  7.     append PREFS "-v[lindex [split ${alpha::version} .] 0]"
  8.     # check if the user over-rides things
  9.     if {[file exists ${HOME}:AlphaPrefs] && [file isdir ${HOME}:AlphaPrefs]} {
  10.         set PREFS ${HOME}:AlphaPrefs
  11.     } else {        
  12.         if {[info tclversion] < 8.0} {
  13.             if ![file exists $PREFS] { oldMkdir [list $PREFS] }
  14.         } else {
  15.             if ![file exists $PREFS] { file mkdir $PREFS }
  16.         }
  17.     }
  18.     # source v. important code
  19.     source "$HOME:Tcl:SystemCode:library.tcl"
  20.     alpha::makeAutoPath 0 $skipPrefs
  21.     alpha::fixCoreBugs
  22.     # get known packages
  23.     catch {cache::read index::extension}
  24.     if {![cache::exists index::mode] \
  25.       || ([alpha::package versions Alpha] != ${alpha::version})} {
  26.         alertnote "I need to rebuild the package indices.\
  27.           This'll take just a few seconds."
  28.         alpha::makeIndices
  29.     }
  30.     
  31.     if {![alpha::package vsatisfies ${alpha::version} 7.0d1]} {
  32.         alertnote "This version of Alpha is too old. Upgrade from http://www.cs.umd.edu/~keleher/alpha.html\r\rI'll quit now."
  33.         quit
  34.     }
  35.     # load the list of active packages from special cache
  36.     if {!$skipPrefs} {set package::loaded [cache::snippetRead activepackages]}
  37.     
  38. # Now do all the more complex stuff:
  39. # (from now on, avoid use of 'source'.  Prefer to use auto-loading)
  40.  
  41. set alpha::noMenusYet 1
  42.     # pull in smarterSource package if the user activated it
  43.     if {[lsearch -exact ${package::loaded} smarterSource] != -1} {
  44.         alpha::package require smarterSource
  45.     }
  46.     
  47.     removeTemporaryFiles
  48.     alpha::getGlobalPreferences
  49.     alpha::getDefinitions
  50.     if {!$skipPrefs} {
  51.         # Read both scalar and array definitions from preferences folder.
  52.         alpha::readUserDefs
  53.         if [key::optionPressed] {
  54.         }
  55.     }
  56.     # define v. important keyboard variables
  57.     keys::keyboardChanged
  58.     menu::buildBasic
  59.     if ![info exists alpha::haveBasicKeys] {
  60.         alpha::basicKeyBindings
  61.     }
  62.     alpha::keyBindings
  63.     alpha::useElectricTemplates
  64.     # Read in all packages, modes and menus.
  65.     alpha::findAllPlugins
  66.     if {!$skipPrefs} {
  67.         # read preferences file
  68.         if [catch {alpha::readUserPrefs} err] {
  69.             append alpha::errorLog "\r" $err
  70.             unset err
  71.         }
  72.     }
  73.     # call anything that's attached to my keyboard.
  74.     hook::callAll keyboard $keyboard
  75.     # build all menus completely.
  76.     alpha::buildMainMenus
  77.     # insert menus
  78.     global::insertAllMenus
  79.     # adjust enabled status of menus
  80.     catch {endisableMenus}
  81.     # bind special keys
  82.     bind::fromArray keys::specialBindings keys::specialProcs
  83.  
  84. # if we do anything else to a menu, it must now be rebuilt
  85. unset alpha::noMenusYet
  86.  
  87. # couple of random things
  88. alpha::makeColourList
  89.  
  90. # Add to chars considered part of words.
  91. addAlphaChars {_ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÅØæøæß}
  92. # Call all startup hooks
  93. hook::callAll startupHook *
  94. # call these two procs to sort out the menu enabled state.
  95. menuEnableHook 0
  96. requireOpenWindowsHook 2
  97.  
  98. # Alerts and readme's for the user:
  99.  
  100.     if {!$skipPrefs} {
  101.         if {![info exists readReadme] \
  102.             || ($readReadme != [alpha::package versions Alpha])} {
  103.             addDef readReadme [alpha::package versions Alpha]
  104.             edit -r "$HOME:Help:Readme"
  105.         } else {unset readReadme}
  106.         
  107.         if {[info exists alpha::readAtStartup]} {
  108.             foreach f ${alpha::readAtStartup} {
  109.                 catch {edit -r $f}
  110.             }
  111.             unset alpha::readAtStartup
  112.             lappend modifiedVars alpha::readAtStartup
  113.         }
  114.     }
  115.  
  116. } err] {
  117.     append alpha::errorLog "\r" $errorInfo
  118.     alertnote "That was a core startup error.  Alpha will probably not function correctly."
  119. }
  120. if [info exists alpha::errorLog] {
  121.     new -n "* Alpha startup error log *"
  122.     insertText ${alpha::errorLog}
  123.     unset alpha::errorLog
  124.     winReadOnly
  125. }
  126.  
  127. message "Initialization Complete"
  128.  
  129.  
  130.  
  131.